package main;

import java.util.HashMap;

import classes.Unit;
import enums.Category;
import enums.MeasuringSystem;

public class InstanciationUnits {

	private HashMap<String, Unit> units;
	
	/* Getter and Setter */
	public HashMap<String, Unit> getUnits() {
		return units;
	}

	public void setUnits(HashMap<String, Unit> units) {
		this.units = units;
	}
	
	public InstanciationUnits(){
		units = new HashMap<String, Unit>();
		
		/**************************************************************
		 * AREA - BRITISH 
		 **************************************************************/
		// square yard
		Unit yard2 = new Unit();
		yard2.setLabel("Square yard");
		yard2.setSystem(MeasuringSystem.BRITISH);
		yard2.setCategory(Category.AREA);
		
		// square feet
		Unit ft2 = new Unit();
		ft2.setLabel("Square feet");
		ft2.setSystem(MeasuringSystem.BRITISH);
		ft2.setCategory(Category.AREA);
		
		// square inch
		Unit inch2 = new Unit();
		inch2.setLabel("Square inch");
		inch2.setSystem(MeasuringSystem.BRITISH);
		inch2.setCategory(Category.AREA);
		
		//HashMap square yard
		yard2.setConvert(ft2, 9, 0);
		yard2.setConvert(inch2, 1296, 0);
		
		//HashMap square feet
		ft2.setConvert(yard2, 0.11, 0);
		ft2.setConvert(inch2, 144, 0);
		
		//HashMap square inch
		inch2.setConvert(yard2, 0.000772, 0);
		inch2.setConvert(ft2, 0.01, 0);
		
		/**************************************************************
		 * AREA - METRIC
		 **************************************************************/
		// Square kilometer
		Unit km2 = new Unit();
		km2.setLabel("Square kilometer");
		km2.setSystem(MeasuringSystem.METRIC);
		km2.setCategory(Category.AREA);
		
		// Hectare
		Unit ha = new Unit();
		ha.setLabel("Hectare");
		ha.setSystem(MeasuringSystem.METRIC);
		ha.setCategory(Category.AREA);
		
		// Are
		Unit are = new Unit();
		are.setLabel("Are");
		are.setSystem(MeasuringSystem.METRIC);
		are.setCategory(Category.AREA);
		
		// Square meter
		Unit m2 = new Unit();
		m2.setLabel("Square meter");
		m2.setSystem(MeasuringSystem.METRIC);
		m2.setCategory(Category.AREA);
		
		// Square centimeter
		Unit cm2 = new Unit();
		cm2.setLabel("Square centimeter");
		cm2.setSystem(MeasuringSystem.METRIC);
		cm2.setCategory(Category.AREA);
		
		// HashMap Square kilometer
		km2.setConvert(ha, 100, 0);
		km2.setConvert(are, 10000, 0);
		km2.setConvert(m2, 1000000, 0);
		km2.setConvert(cm2, (100000*100000), 0);
		
		// HashMap hectare
		ha.setConvert(km2, 0.01, 0);
		ha.setConvert(are, 100, 0);
		ha.setConvert(m2, 10000, 0);
		ha.setConvert(cm2, 100000000, 0);
		
		// HashMap Are
		are.setConvert(km2, 0.001, 0);
		are.setConvert(ha, 0.01, 0);
		are.setConvert(m2, 100, 0);
		are.setConvert(cm2, 1000000, 0);
		
		//HashMap Square meter
		m2.setConvert(km2, 0.00001, 0);
		m2.setConvert(ha, 0.001, 0);
		m2.setConvert(are, 0.01, 0);
		m2.setConvert(cm2, 10000, 0);
		
		//HashMap Square centimeter
		cm2.setConvert(km2, 0.0000000001, 0);
		cm2.setConvert(ha, 0.0000001, 0);
		cm2.setConvert(are, 0.00001, 0);
		cm2.setConvert(m2, 0.001, 0);
		
		/**************************************************************
		 * SUPERFICIE - Conversion between systems 
		 **************************************************************/
		yard2.setRef(true);
		m2.setRef(true);
		yard2.setConvert(m2, 0.84, 0);
		m2.setConvert(yard2, 1.2, 0);
		
		units.put("yard2", yard2);
		units.put("feet2", ft2);
		units.put("inch2", inch2);
		units.put("km2", km2);
		units.put("ha", ha);
		units.put("are", are);
		units.put("m2", m2);
		units.put("cm2", cm2);
		
		/**************************************************************
		 * SPEED - BRITISH 
		 **************************************************************/
		// Miles / hour
		Unit mph = new Unit();
		mph.setLabel("Miles per hour");
		mph.setSystem(MeasuringSystem.BRITISH);
		mph.setCategory(Category.SPEED);
		
		/**************************************************************
		 * SPEED - METRIC 
		 **************************************************************/
		// Kilometer / heure
		Unit kmh = new Unit();
		kmh.setLabel("Kilometer per hour");
		kmh.setSystem(MeasuringSystem.METRIC);
		kmh.setCategory(Category.SPEED);
		
		/**************************************************************
		 * SPEED - Conversion between systems  
		 **************************************************************/
		mph.setRef(true);
		kmh.setRef(true);
		mph.setConvert(kmh, 1.61, 0);
		kmh.setConvert(mph, 0.62, 0);
		
		units.put("mph", mph);
		units.put("kmh", kmh);
		
		/**************************************************************
		 * MONNAIE - Monetary 
		 **************************************************************/
		// Euro
		Unit eur = new Unit();
		eur.setLabel("Euro");
		eur.setSystem(MeasuringSystem.MONETARY);
		eur.setCategory(Category.CURRENCY);
		
		// US Dollar
		Unit usd = new Unit();
		usd.setLabel("US Dollar");
		usd.setSystem(MeasuringSystem.MONETARY);
		usd.setCategory(Category.CURRENCY);
		
		// Great Britain Pound
		Unit gbp = new Unit();
		gbp.setLabel("Livre sterling");
		gbp.setSystem(MeasuringSystem.MONETARY);
		gbp.setCategory(Category.CURRENCY);
		
		// Japan Yen
		Unit jpy = new Unit();
		jpy.setLabel("Yen japonaise");
		jpy.setSystem(MeasuringSystem.MONETARY);
		jpy.setCategory(Category.CURRENCY);
		
		// Marocan Dirham
		Unit mad = new Unit();
		mad.setLabel("Dirham marocain");
		mad.setSystem(MeasuringSystem.MONETARY);
		mad.setCategory(Category.CURRENCY);
		
		// hashMap euro
		eur.setConvert(usd, 1.38, 0);
		eur.setConvert(gbp, 0.81, 0);
		eur.setConvert(jpy, 141.04, 0);
		eur.setConvert(mad, 11.3, 0);
		
		// hashMap US dollar
		usd.setConvert(eur, 0.73, 0);
		usd.setConvert(gbp, 0.59, 0);
		usd.setConvert(jpy, 102.53, 0);
		usd.setConvert(mad, 8.21, 0);
		
		// hashMap Great Britain pound
		gbp.setConvert(eur, 1.23, 0);
		gbp.setConvert(usd, 1.7, 0);
		gbp.setConvert(jpy, 173.92, 0);
		gbp.setConvert(mad, 13.93, 0);
		
		// hashMap Japan Yen
		jpy.setConvert(eur, 0.01, 0);
		jpy.setConvert(usd, 0.01, 0);
		jpy.setConvert(gbp, 0.01, 0);
		jpy.setConvert(mad, 0.08, 0);
		
		// hashMap Marocan Dirham
		mad.setConvert(eur, 0.09, 0);
		mad.setConvert(usd, 0.12, 0);
		mad.setConvert(gbp, 0.07, 0);
		mad.setConvert(jpy, 12.48, 0);
		
		units.put("eur", eur);
		units.put("usd", usd);
		units.put("gbp", gbp);
		units.put("jpy", jpy);
		units.put("mad", mad);
		
		/**************************************************************
		 * TEMPERATURE - BRITISH 
		 **************************************************************/
		Unit fahrenheit = new Unit();
		fahrenheit.setLabel("Fahrenheit Degree");
		fahrenheit.setSystem(MeasuringSystem.BRITISH);
		fahrenheit.setCategory(Category.TEMPERATURE);
		
		/**************************************************************
		 * TEMPERATURE - METRIC 
		 **************************************************************/
		Unit celsius = new Unit();
		celsius.setLabel("Celsius Degree");
		celsius.setSystem(MeasuringSystem.METRIC);
		celsius.setCategory(Category.TEMPERATURE);
		
		/**************************************************************
		 * TEMPERATURE - Conversion between systems  
		 **************************************************************/
		double factor = 5.0 /9.0 ;
		fahrenheit.setConvert(celsius, factor, 32);
		factor = 9.0 /5.0;
		celsius.setConvert(fahrenheit, factor, 32);
		
		units.put("fahrenheit", fahrenheit);
		units.put("celsius", celsius);
		
		/**************************************************************
		 * MASSE - METRIC 
		 **************************************************************/
		// Tonne
		Unit tonne = new Unit();
		tonne.setLabel("Tonne");
		tonne.setSystem(MeasuringSystem.METRIC);
		tonne.setCategory(Category.MASS);
		
		// Kilogram
		Unit kilogram = new Unit();
		kilogram.setLabel("Kilogram");
		kilogram.setSystem(MeasuringSystem.METRIC);
		kilogram.setCategory(Category.MASS);
		
		// Hectogram
		Unit hectogram = new Unit();
		hectogram.setLabel("Hectogram");
		hectogram.setSystem(MeasuringSystem.METRIC);
		hectogram.setCategory(Category.MASS);
		
		// Gram
		Unit gram = new Unit();
		gram.setLabel("Gram");
		gram.setSystem(MeasuringSystem.METRIC);
		gram.setCategory(Category.MASS);
		
		// Centigram
		Unit centigram = new Unit();
		centigram.setLabel("Centigram");
		centigram.setSystem(MeasuringSystem.METRIC);
		centigram.setCategory(Category.MASS);
		
		// Milligram
		Unit milligram = new Unit();
		milligram.setLabel("Milligram");
		milligram.setSystem(MeasuringSystem.METRIC);
		milligram.setCategory(Category.MASS);
		
		// Microgram
		Unit microgram = new Unit();
		microgram.setLabel("Microgram");
		microgram.setSystem(MeasuringSystem.METRIC);
		microgram.setCategory(Category.MASS);
		
		// Nanogram
		Unit nanogram = new Unit();
		nanogram.setLabel("Nanogram");
		nanogram.setSystem(MeasuringSystem.METRIC);
		nanogram.setCategory(Category.MASS);
		
		// Conversion --
		// -- from tonne
		tonne.setConvert(kilogram, 1000, 0);
		tonne.setConvert(hectogram, 10000, 0);
		tonne.setConvert(gram, 1000000, 0);
		tonne.setConvert(centigram, 100000000, 0);
		tonne.setConvert(milligram, 1000000000, 0);
		tonne.setConvert(microgram, 10e12, 0);
		tonne.setConvert(nanogram, 10e15, 0);
		
		// -- from kilogramme
		kilogram.setConvert(tonne, 0.001, 0);
		kilogram.setConvert(hectogram, 10, 0);
		kilogram.setConvert(gram, 1000, 0);
		kilogram.setConvert(centigram, 100000, 0);
		kilogram.setConvert(milligram, 1000000, 0);
		kilogram.setConvert(microgram, 1000000000, 0);
		kilogram.setConvert(nanogram, 10e12, 0);
		
		// -- from hectogramme
		hectogram.setConvert(tonne, 0.0001, 0);
		hectogram.setConvert(kilogram, 0.1, 0);
		hectogram.setConvert(gram, 100, 0);
		hectogram.setConvert(centigram, 10000, 0);
		hectogram.setConvert(milligram, 100000, 0);
		hectogram.setConvert(microgram, 100000000, 0);
		hectogram.setConvert(nanogram, 10e11, 0);
		
		// -- from gram
		gram.setConvert(tonne, 0.000001, 0);
		gram.setConvert(kilogram, 0.001, 0);
		gram.setConvert(hectogram, 0.01, 0);
		gram.setConvert(centigram, 100, 0);
		gram.setConvert(milligram, 1000, 0);
		gram.setConvert(microgram, 1000000, 0);
		gram.setConvert(nanogram, 1000000000, 0);
		
		// -- from centigram
		centigram.setConvert(tonne, 0.00000001, 0);
		centigram.setConvert(kilogram, 0.00001, 0);
		centigram.setConvert(hectogram, 0.0001, 0);
		centigram.setConvert(gram, 0.01, 0);
		centigram.setConvert(milligram, 10, 0);
		centigram.setConvert(microgram, 10000, 0);
		centigram.setConvert(nanogram, 10000000, 0);
		
		// -- from milligram
		milligram.setConvert(tonne, 10e-9, 0);
		milligram.setConvert(kilogram, 10e-6, 0);
		milligram.setConvert(hectogram, 0.00001, 0);
		milligram.setConvert(gram, 0.001, 0);
		milligram.setConvert(centigram, 0.1, 0);
		milligram.setConvert(microgram, 1000, 0);
		milligram.setConvert(nanogram, 1000000, 0);
		
		// -- from microgram
		microgram.setConvert(tonne, 10e-12, 0);
		microgram.setConvert(kilogram, 10e-9, 0);
		microgram.setConvert(hectogram, 0.00000001, 0);
		microgram.setConvert(gram, 0.000001, 0);
		microgram.setConvert(centigram, 0.0001, 0);
		microgram.setConvert(milligram, 0.001, 0);
		microgram.setConvert(nanogram, 1000, 0);
		
		// -- from nanogram
		nanogram.setConvert(tonne, 10e-15, 0);
		nanogram.setConvert(kilogram, 10e-12, 0);
		nanogram.setConvert(hectogram, 10e-11, 0);
		nanogram.setConvert(gram, 10e-9, 0);
		nanogram.setConvert(centigram, 0.0000001, 0);
		nanogram.setConvert(milligram, 0.000001, 0);
		nanogram.setConvert(microgram, 0.001, 0);
		
		/**************************************************************
		 * MASSE - BRITISH 
		 **************************************************************/
		// Long Ton
		Unit longTon = new Unit();
		longTon.setLabel("LongTon");
		longTon.setSystem(MeasuringSystem.BRITISH);
		longTon.setCategory(Category.MASS);
		
		// Short Ton
		Unit shortTon = new Unit();
		shortTon.setLabel("ShortTon");
		shortTon.setSystem(MeasuringSystem.BRITISH);
		shortTon.setCategory(Category.MASS);
		
		// Liver (lb)
		Unit lb = new Unit();
		lb.setLabel("Liver");
		lb.setSystem(MeasuringSystem.BRITISH);
		lb.setCategory(Category.MASS);
		
		// Conversion -- 
		// -- from longTon
		longTon.setConvert(shortTon, 1.12, 0);
		longTon.setConvert(lb, 2240, 0);
		
		// -- from shortTon
		shortTon.setConvert(longTon, 0.89, 0);
		shortTon.setConvert(lb, 2000, 0);
		
		// -- from pound
		lb.setConvert(longTon, 0.000446, 0);
		lb.setConvert(shortTon, 0.0005, 0);
		
		/**************************************************************
		 * MASSE - Conversion between systems
		 **************************************************************/
		kilogram.setRef(true);
		lb.setRef(true);
		kilogram.setConvert(lb, 2.2, 0);
		lb.setConvert(kilogram, 0.45, 0);
		
		units.put("tonne", tonne);
		units.put("kilogram", kilogram);
		units.put("hectogram", hectogram);
		units.put("gram", gram);
		units.put("centigram", centigram);
		units.put("milligram", milligram);
		units.put("microgram", microgram);
		units.put("nanogram", nanogram);
		units.put("longTon", longTon);
		units.put("shortTon", shortTon);
		units.put("lb", lb);
		
		/**************************************************************
		 * VOLUME - METRIC 
		 **************************************************************/
		// km3
		Unit km3 = new Unit();
		km3.setLabel("km3");
		km3.setSystem(MeasuringSystem.METRIC);
		km3.setCategory(Category.VOLUME);
		
		// m3
		Unit m3 = new Unit();
		m3.setLabel("m3");
		m3.setSystem(MeasuringSystem.METRIC);
		m3.setCategory(Category.VOLUME);
		
		// dm3
		Unit dm3 = new Unit();
		dm3.setLabel("dm3");
		dm3.setSystem(MeasuringSystem.METRIC);
		dm3.setCategory(Category.VOLUME);
		
		// cm3
		Unit cm3 = new Unit();
		cm3.setLabel("cm3");
		cm3.setSystem(MeasuringSystem.METRIC);
		cm3.setCategory(Category.VOLUME);
		
		// mm3
		Unit mm3 = new Unit();
		mm3.setLabel("mm3");
		mm3.setSystem(MeasuringSystem.METRIC);
		mm3.setCategory(Category.VOLUME);
		
		// Decaliter
		Unit decaliter = new Unit();
		decaliter.setLabel("Decaliter");
		decaliter.setSystem(MeasuringSystem.METRIC);
		decaliter.setCategory(Category.VOLUME);
		
		// Liter
		Unit liter = new Unit();
		liter.setLabel("Liter");
		liter.setSystem(MeasuringSystem.METRIC);
		liter.setCategory(Category.VOLUME);
		
		// Deciliter
		Unit deciliter = new Unit();
		deciliter.setLabel("Deciliter");
		deciliter.setSystem(MeasuringSystem.METRIC);
		deciliter.setCategory(Category.VOLUME);
		
		// Centiliter
		Unit centiliter = new Unit();
		centiliter.setLabel("Centiliter");
		centiliter.setSystem(MeasuringSystem.METRIC);
		centiliter.setCategory(Category.VOLUME);
		
		// Milliliter
		Unit milliliter = new Unit();
		milliliter.setLabel("Milliliter");
		milliliter.setSystem(MeasuringSystem.METRIC);
		milliliter.setCategory(Category.VOLUME);
		
		// Conversion --
		// -- from km3
		km3.setConvert(m3, 10e9, 0);
		km3.setConvert(dm3, 10e12, 0);
		km3.setConvert(cm3, 10e15, 0);
		km3.setConvert(mm3, 10e18, 0);
		km3.setConvert(decaliter, 10e11, 0);
		km3.setConvert(liter, 10e12, 0);
		km3.setConvert(deciliter, 10e13, 0);
		km3.setConvert(centiliter, 10e14, 0);
		km3.setConvert(milliliter, 10e15, 0);
		
		// -- from m3
		m3.setConvert(km3, 10e-9, 0);
		m3.setConvert(dm3, 1000, 0);
		m3.setConvert(cm3, 10e6, 0);
		m3.setConvert(mm3, 10e9, 0);
		m3.setConvert(decaliter, 100, 0);
		m3.setConvert(liter, 1000, 0);
		m3.setConvert(deciliter, 10000, 0);
		m3.setConvert(centiliter, 100000, 0);
		m3.setConvert(milliliter, 1000000, 0);
		
		// -- from dm3
		dm3.setConvert(km3, 10e-12, 0);
		dm3.setConvert(m3, 10e-3, 0);
		dm3.setConvert(cm3, 1000, 0);
		dm3.setConvert(mm3, 10e6, 0);
		dm3.setConvert(decaliter, 0.1, 0);
		dm3.setConvert(liter, 1, 0);
		dm3.setConvert(deciliter, 10, 0);
		dm3.setConvert(centiliter, 100, 0);
		dm3.setConvert(milliliter, 1000, 0);
		
		// -- from cm3
		cm3.setConvert(km3, 10e-15, 0);
		cm3.setConvert(m3, 10e-6, 0);
		cm3.setConvert(dm3, 0.001, 0);
		cm3.setConvert(mm3, 1000, 0);
		cm3.setConvert(decaliter, 0.0001, 0);
		cm3.setConvert(liter, 0.001, 0);
		cm3.setConvert(deciliter, 0.01, 0);
		cm3.setConvert(centiliter, 0.1, 0);
		cm3.setConvert(milliliter, 1, 0);
		
		// -- from mm3
		mm3.setConvert(km3, 10e-18, 0);
		mm3.setConvert(m3, 10e-9, 0);
		mm3.setConvert(dm3, 10e-6, 0);
		mm3.setConvert(cm3, 10e-3, 0);
		mm3.setConvert(decaliter, 10e-7, 0);
		mm3.setConvert(liter, 10e-6, 0);
		mm3.setConvert(deciliter, 10e-5, 0);
		mm3.setConvert(centiliter, 10e-4, 0);
		mm3.setConvert(milliliter, 10e-3, 0);
		
		// -- from decaliter
		decaliter.setConvert(km3, 10e-11, 0);
		decaliter.setConvert(m3, 0.01, 0);
		decaliter.setConvert(dm3, 10, 0);
		decaliter.setConvert(cm3, 10000, 0);
		decaliter.setConvert(mm3, 10000000, 0);
		decaliter.setConvert(liter, 10, 0);
		decaliter.setConvert(deciliter, 100, 0);
		decaliter.setConvert(centiliter, 1000, 0);
		decaliter.setConvert(milliliter, 10000, 0);
		
		// -- from liter
		liter.setConvert(km3, 10e-12, 0);
		liter.setConvert(m3, 10e-3, 0);
		liter.setConvert(dm3, 1, 0);
		liter.setConvert(cm3, 1000, 0);
		liter.setConvert(mm3, 1000000, 0);
		liter.setConvert(decaliter, 0.1, 0);
		liter.setConvert(deciliter, 10, 0);
		liter.setConvert(centiliter, 100, 0);
		liter.setConvert(milliliter, 1000, 0);
		
		// -- from deciliter
		deciliter.setConvert(km3, 10e-13, 0);
		deciliter.setConvert(m3, 10e-4, 0);
		deciliter.setConvert(dm3, 0.1, 0);
		deciliter.setConvert(cm3, 100, 0);
		deciliter.setConvert(mm3, 100000, 0);
		deciliter.setConvert(decaliter, 0.01, 0);
		deciliter.setConvert(liter, 0.1, 0);
		deciliter.setConvert(centiliter, 10, 0);
		deciliter.setConvert(milliliter, 100, 0);
		
		// -- from centiliter
		centiliter.setConvert(km3, 10e-14, 0);
		centiliter.setConvert(m3, 10e-5, 0);
		centiliter.setConvert(dm3, 0.01, 0);
		centiliter.setConvert(cm3, 10, 0);
		centiliter.setConvert(mm3, 10000, 0);
		centiliter.setConvert(decaliter, 0.001, 0);
		centiliter.setConvert(liter, 0.01, 0);
		centiliter.setConvert(deciliter, 0.1, 0);
		centiliter.setConvert(milliliter, 10, 0);
		
		// -- from milliliter
		milliliter.setConvert(km3, 10e-15, 0);
		milliliter.setConvert(m3, 10e-6, 0);
		milliliter.setConvert(dm3, 10e-3, 0);
		milliliter.setConvert(cm3, 1, 0);
		milliliter.setConvert(mm3, 1000, 0);
		milliliter.setConvert(decaliter, 0.0001, 0);
		milliliter.setConvert(liter, 0.001, 0);
		milliliter.setConvert(deciliter, 0.01, 0);
		milliliter.setConvert(centiliter, 0.1, 0);
		
		/**************************************************************
		 * VOLUME - BRITISH 
		 **************************************************************/
		// Barrel
		Unit barrel = new Unit();
		barrel.setLabel("Barrel");
		barrel.setSystem(MeasuringSystem.BRITISH);
		barrel.setCategory(Category.VOLUME);
		
		// Gallon
		Unit gallon = new Unit();
		gallon.setLabel("Gallon");
		gallon.setSystem(MeasuringSystem.BRITISH);
		gallon.setCategory(Category.VOLUME);
		
		// Conversion --
		// -- from barrel
		barrel.setConvert(gallon, 36, 0);
		
		// -- from gallon
		gallon.setConvert(barrel, 0.03, 0);
		
		/**************************************************************
		 * VOLUME - Conversion between systems 
		 **************************************************************/
		liter.setRef(true);
		gallon.setRef(true);
		liter.setConvert(gallon, 0.22, 0);
		gallon.setConvert(liter, 4.55, 0);
		
		units.put("km3", km3);
		units.put("m3", m3);
		units.put("dm3", dm3);
		units.put("cm3", cm3);
		units.put("mm3", mm3);
		units.put("decaliter", decaliter);
		units.put("liter", liter);
		units.put("deciliter", deciliter);
		units.put("centiliter", centiliter);
		units.put("milliliter", milliliter);
		units.put("barrel", barrel);
		units.put("gallon", gallon);
		
		/**************************************************************
		 * LONGUEUR - METRIC 
		 **************************************************************/
		// Kilometer
		Unit kilometer = new Unit();
		kilometer.setLabel("Kilometer");
		kilometer.setSystem(MeasuringSystem.METRIC);
		kilometer.setCategory(Category.LENGTH);
		
		// meter
		Unit meter = new Unit();
		meter.setLabel("Meter");
		meter.setSystem(MeasuringSystem.METRIC);
		meter.setCategory(Category.LENGTH);

		// Decimeter
		Unit decimeter = new Unit();
		decimeter.setLabel("Decimeter");
		decimeter.setSystem(MeasuringSystem.METRIC);
		decimeter.setCategory(Category.LENGTH);
		
		// Centimeter
		Unit centimeter = new Unit();
		centimeter.setLabel("Centimeter");
		centimeter.setSystem(MeasuringSystem.METRIC);
		centimeter.setCategory(Category.LENGTH);
		
		// Millimeter
		Unit millimeter = new Unit();
		millimeter.setLabel("Millimeter");
		millimeter.setSystem(MeasuringSystem.METRIC);
		millimeter.setCategory(Category.LENGTH);
		
		// Micrometer
		Unit micrometer = new Unit();
		micrometer.setLabel("Micrometer");
		micrometer.setSystem(MeasuringSystem.METRIC);
		micrometer.setCategory(Category.LENGTH);
		
		// Nanometer
		Unit nanometer = new Unit();
		nanometer.setLabel("Nanometer");
		nanometer.setSystem(MeasuringSystem.METRIC);
		nanometer.setCategory(Category.LENGTH);
		
		// Conversion --
		// -- from kilometer
		kilometer.setConvert(meter, 1000, 0);
		kilometer.setConvert(decimeter, 10000, 0);
		kilometer.setConvert(centimeter, 100000, 0);
		kilometer.setConvert(millimeter, 1000000, 0);
		kilometer.setConvert(micrometer, 1000000000, 0);
		kilometer.setConvert(nanometer, 10e12, 0);
		
		// -- from meter
		meter.setConvert(kilometer, 0.001, 0);
		meter.setConvert(decimeter, 10, 0);
		meter.setConvert(centimeter, 100, 0);
		meter.setConvert(millimeter, 1000, 0);
		meter.setConvert(micrometer, 1000000, 0);
		meter.setConvert(nanometer, 1000000000, 0);
		
		// -- from decimeter
		decimeter.setConvert(kilometer, 0.0001, 0);
		decimeter.setConvert(meter, 0.1, 0);
		decimeter.setConvert(centimeter, 10, 0);
		decimeter.setConvert(millimeter, 100, 0);
		decimeter.setConvert(micrometer, 100000, 0);
		decimeter.setConvert(nanometer, 100000000, 0);
		
		// -- from centimeter
		centimeter.setConvert(kilometer, 0.00001, 0);
		centimeter.setConvert(meter, 0.01, 0);
		centimeter.setConvert(decimeter, 0.1, 0);
		centimeter.setConvert(millimeter, 10, 0);
		centimeter.setConvert(micrometer, 10000, 0);
		centimeter.setConvert(nanometer, 10000000, 0);
		
		// -- from millimeter
		millimeter.setConvert(kilometer, 0.000001, 0);
		millimeter.setConvert(meter, 0.001, 0);
		millimeter.setConvert(decimeter, 0.01, 0);
		millimeter.setConvert(centimeter, 0.1, 0);
		millimeter.setConvert(micrometer, 1000, 0);
		millimeter.setConvert(nanometer, 1000000, 0);
		
		// -- from micrometer
		micrometer.setConvert(kilometer, 0.000000001, 0);
		micrometer.setConvert(meter, 0.000001, 0);
		micrometer.setConvert(decimeter, 0.00001, 0);
		micrometer.setConvert(centimeter, 0.0001, 0);
		micrometer.setConvert(millimeter, 0.001, 0);
		micrometer.setConvert(nanometer, 1000, 0);
		
		// -- from nanometer
		nanometer.setConvert(kilometer, 10e-12, 0);
		nanometer.setConvert(meter, 0.000000001, 0);
		nanometer.setConvert(decimeter, 0.00000001, 0);
		nanometer.setConvert(centimeter, 0.0000001, 0);
		nanometer.setConvert(millimeter, 0.000001, 0);
		nanometer.setConvert(micrometer, 0.001, 0);
		
		/**************************************************************
		 * LONGUEUR - BRITISH
		 **************************************************************/
		// Mile
		Unit mile = new Unit();
		mile.setLabel("Mile");
		mile.setSystem(MeasuringSystem.BRITISH);
		mile.setCategory(Category.LENGTH);
		
		// Yard
		Unit yard = new Unit();
		yard.setLabel("Yard");
		yard.setSystem(MeasuringSystem.BRITISH);
		yard.setCategory(Category.LENGTH);
		
		// Pied 
		Unit feet = new Unit();
		feet.setLabel("Feet");
		feet.setSystem(MeasuringSystem.BRITISH);
		feet.setCategory(Category.LENGTH);
		
		// Inch
		Unit inch = new Unit();
		inch.setLabel("Inch");
		inch.setSystem(MeasuringSystem.BRITISH);
		inch.setCategory(Category.LENGTH);
		
		// Conversion --
		// -- from mile
		mile.setConvert(yard, 1760, 0);
		mile.setConvert(feet, 5280, 0);
		mile.setConvert(inch, 63360, 0);
		
		// -- from yard
		yard.setConvert(mile, 0.000568, 0);
		yard.setConvert(feet, 3, 0);
		yard.setConvert(inch, 36, 0);
		
		// -- from feet
		feet.setConvert(mile, 0.000189, 0);
		feet.setConvert(yard, 0.33, 0);
		feet.setConvert(inch, 12, 0);
		
		// -- from inch
		inch.setConvert(mile, 0.0000158, 0);
		inch.setConvert(yard, 0.03, 0);
		inch.setConvert(feet, 0.08, 0);
		
		/**************************************************************
		 * LONGUEUR - Conversion between systems 
		 **************************************************************/
		kilometer.setRef(true);
		mile.setRef(true);
		kilometer.setConvert(mile, 0.62, 0);
		mile.setConvert(kilometer, 1.61, 0);
		
		units.put("kilometer", kilometer);
		units.put("meter", meter);
		units.put("decimeter", decimeter);
		units.put("centimeter", centimeter);
		units.put("millimeter", millimeter);
		units.put("micrometer", micrometer);
		units.put("nanometer", nanometer);
		units.put("mile", mile);
		units.put("yard", yard);
		units.put("feet", feet);
		units.put("inch", inch);
	}

	

}
